package game.ui.controls
{
	import engine.asset.*;
	import flash.events.*;
	import flash.text.*;
	import game.actor.*;
	import game.localization.*;
	import game.messages.gamedata.*;
	import game.network.*;
	import game.scene.*;
	import game.ui.core.*;
	
	public class RxEquipmentTooltip extends RxTooltip
	{
		private var m_itemRecord:RxItemRecord;
		private var m_simple:Boolean;
		private var m_type:String;
		private var m_goldLabel:RxTextLabel;
		private var m_statIcon:RxBitmap;
		private var m_statLabel:RxTextLabel;
		private var m_descriptionLabel:RxTextLabel;
		private var m_sellLabel:RxTextLabel;
		private var m_currentlyEquipLabel:RxTextLabel;
		private var m_showSellLabel:Boolean = false;
		private var m_showErrorLabel:Boolean = true;
		private var m_compareRenderStyle:Boolean;
		private var m_equipIndex:int;
		private var m_errorField:RxTextLabel;
		private var m_highlighted:Boolean;
		
		public function RxEquipmentTooltip(param1:RxItemRecord, param2:Boolean, param3:Boolean = false, param4:String = null, param5:Boolean = false)
		{
			super(param4, false, !param3);
			this.m_simple = param2;
			this.m_compareRenderStyle = param3;
			mouseEnabled = false;
			mouseChildren = false;
			this.SetShowSellValue(param5);
			if (param1)
			{
				this.SetData(param1);
			}
		}
		
		public function SetShowSellValue(param1:Boolean) : void
		{
			this.m_showSellLabel = param1;
		}
		
		override public function SetData(param1:Object, param2:Boolean = false) : void
		{
			var _loc_4:RxItemPackageAsset = null;
			this.m_itemRecord = param1 as RxItemRecord;
			var _loc_3:* = RxAssetCSV.GetByName(RxGameData_NameSpace.ITEM);
			if (this.m_itemRecord && !_loc_3.RowExists(this.m_itemRecord.GetBaseDefinition()))
			{
				_loc_4 = new RxItemPackageAsset(this.m_itemRecord.GetBaseDefinition());
				_loc_4.AddCallback(new RxAssetCallback(this.OnItemPackageLoaded));
				_loc_4.Load();
			}
			else
			{
				this.CreateTooltip();
			}
		}
		
		private function OnItemPackageLoaded(param1:RxAssetCallback) : void
		{
			this.CreateTooltip();
		}
		
		private function CreateTooltip() : void
		{
			var _loc_1:* = RxAssetCSV.GetByName(RxGameData_NameSpace.ITEM);
			if (this.m_itemRecord)
			{
				this.m_type = _loc_1.GetMappedString("type", this.m_itemRecord.GetBaseDefinition());
			}
			else
			{
				this.m_type = null;
			}
			if (this.m_simple)
			{
				this.CreateSimpleTooltip();
			}
			else
			{
				this.CreateDetailedTooltip();
			}
			m_initialized = true;
			InvalidateSize();
			this.UpdateDisplayState();
		}
		
		private function CreateDetailedTooltip() : void
		{
			/*
			var _loc_4:RxAssetCSV = null;
			var _loc_5:String = null;
			var _loc_6:Vector.<String> = null;
			var _loc_1:* = this.m_type == "consumable";
			var _loc_2:* = this.m_type == "currency";
			var _loc_3:* = !_loc_2 && !_loc_1;
			if (m_titleField)
			{
				m_titleField.SetTextFormat(RxFontLibrary.GenerateTextFormatForStyle(RxFontStyleConstants.BODY_MEDIUM_BOLD, 16777215, TextFormatAlign.CENTER));
				m_titleField.textColor = 16777215;
				m_titleField.SetMultiline(true);
				m_titleField.width = 180;
				this.UpdateItemName();
			}
			if (this.m_itemRecord)
			{
				if (!_loc_1 && this.m_errorField && this.m_errorField.parent)
				{
					m_container.removeChild(this.m_errorField);
				}
				if (!_loc_2)
				{
					if (this.m_compareRenderStyle)
					{
						if (!this.m_currentlyEquipLabel)
						{
							this.m_currentlyEquipLabel = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_SMALL, 16777215, TextFormatAlign.CENTER);
							this.m_currentlyEquipLabel.text = "CURRENTLY EQUIPPED";
							this.m_currentlyEquipLabel.SetBackgroundColor(13421721, 0.5);
							m_container.addChild(this.m_currentlyEquipLabel);
						}
						SetBorderStyle(2, 11184759);
					}
					else
					{
						SetBorderStyle(0, 0);
					}
					if (this.m_showSellLabel)
					{
						if (!this.m_goldLabel)
						{
							this.m_goldLabel = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_LARGE_BOLD, 11194937);
							this.m_goldLabel.SetIconUrl("ui/icons/icon_coin_med.png", 23, 23);
						}
						if (!this.m_goldLabel.parent)
						{
							m_container.addChild(this.m_goldLabel);
						}
						this.m_goldLabel.text = RxLocalizationManager.FormatCurrencyValue(this.m_itemRecord.GetSell());
						if (!this.m_sellLabel)
						{
							this.m_sellLabel = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_SMALL, 13421772);
							m_container.addChild(this.m_sellLabel);
						}
						if (!this.m_sellLabel.parent)
						{
							m_container.addChild(this.m_sellLabel);
						}
						this.m_sellLabel.text = "Sell Value";
					}
					else
					{
						if (this.m_sellLabel && this.m_sellLabel.parent)
						{
							m_container.removeChild(this.m_sellLabel);
						}
						if (this.m_goldLabel && this.m_goldLabel.parent)
						{
							m_container.removeChild(this.m_goldLabel);
						}
					}
				}
				if (!this.m_descriptionLabel)
				{
					this.m_descriptionLabel = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_SMALL_BOLD, 16777215, TextFormatAlign.LEFT, true);
					this.m_descriptionLabel.width = 180;
					m_container.addChild(this.m_descriptionLabel);
				}
				if (_loc_3)
				{
					if (!this.m_statIcon)
					{
						this.m_statIcon = new RxBitmap();
						this.m_statIcon.alpha = 0.5;
						m_container.addChild(this.m_statIcon);
					}
					if (!this.m_statLabel)
					{
						this.m_statLabel = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_SMALL_BOLD, 9605258);
						m_container.addChild(this.m_statLabel);
					}
					this.m_statLabel.visible = true;
					this.m_statIcon.visible = true;
					this.UpdateMainStatValue();
					this.m_descriptionLabel.textColor = 8297214;
					this.m_descriptionLabel.text = this.m_itemRecord.GetAttributeString(false);
				}
				else
				{
					_loc_4 = RxAssetCSV.GetByName(RxGameData_NameSpace.ITEM);
					_loc_5 = _loc_4.GetMappedString("toolTip", this.m_itemRecord.GetBaseDefinition());
					if (_loc_5)
					{
						this.m_descriptionLabel.text = _loc_5;
						this.m_descriptionLabel.textColor = 16777215;
					}
					if (this.m_statLabel)
					{
						this.m_statLabel.visible = false;
					}
					if (this.m_statIcon)
					{
						this.m_statIcon.visible = false;
					}
					if (_loc_1 && this.m_showErrorLabel)
					{
						_loc_6 = new Vector.<String>;
						if (!this.m_itemRecord.CanBeUsed(_loc_6))
						{
							if (!this.m_errorField)
							{
								this.m_errorField = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_SMALL_BOLD, 10066329);
							}
							if (_loc_6.length > 0)
							{
								this.m_errorField.text = RxItemRecord.GetLabelForUseFailCondition(_loc_6[0]);
							}
							else
							{
								this.m_errorField.text = "You can\'t use this right now";
							}
							m_container.addChild(this.m_errorField);
						}
						else if (this.m_errorField && this.m_errorField.parent)
						{
							m_container.removeChild(this.m_errorField);
						}
					}
				}
			}
			InvalidateSize();
			*/
		}
		
		private function CreateSimpleTooltip() : void
		{
			this.UpdateItemName();
		}
		
		private function UpdateItemName() : void
		{
			var _loc_2:String = null;
			var _loc_3:String = null;
			var _loc_4:uint = 0;
			var _loc_1:* = RxAssetCSV.GetByName(RxGameData_NameSpace.ITEM);
			if (this.m_itemRecord)
			{
				_loc_2 = this.m_itemRecord.GetBaseDefinition();
				_loc_3 = _loc_1.GetMappedString("dispName", _loc_2);
				m_titleField.text = _loc_3 == null ? ("Unknown Item Name") : (_loc_3);
				_loc_4 = RxInventory.GetLabelColorForItem(_loc_2);
				if (_loc_4 == 0)
				{
					_loc_4 = 16777215;
				}
				if (_loc_4 != 0)
				{
					m_titleField.textColor = _loc_4;
				}
			}
			else
			{
				m_titleField.text = "Nothing equipped\n\nDrag an item here to equip it to this slot.";
				m_titleField.textColor = 12040119;
			}
		}
	}
}